<template>
  <div class="movie_body" ref="movie_body">
    <Loading v-if="isLoading"/>
    <Scroller v-else
      :hanleToTouchEnd="hanleToTouchEnd"
      :handleToScroller="handleToScroller"
    >
      <ul>
        <!-- <li>
          <div class="pic_show"><img src="/images/movie_1.jpg" /></div>
          <div class="info_list">
            <h2>无名之辈</h2>
            <p><span class="person">17746</span> 人想看</p>
            <p>主演: 陈建斌,任素汐,潘斌龙</p>
            <p>2018-11-30上映</p>
          </div>
          <div class="btn_pre">预售</div>
        </li> -->

        <li class="pullDown">{{ pullDown }}</li>
        <li v-for="item in hotMoive" :key="item.id">
          <div class="pic_show" @click="handleToDetail">
            <img :src="item.imgLink" />
          </div>
          <div class="info_list">
            <h2>{{ item.nm }}</h2>
            <font size="2px">{{
              ("" + item.version).indexOf("/") > -1
                ? item.version.split("/")[0]
                : ""
            }}</font>
            <p><span class="person">观众评分：</span> {{ item.score }}</p>
            <p>主演: {{ item.star }}</p>
            <p>{{ item.showInfo }}</p>
          </div>
          <div :class="item.status === '购票' ? 'btn_pre' : 'btn_pre2'">
            {{ item.status }}
          </div>
          <!-- <div class="btn_pre">{{item.status}}</div> -->
        </li>
      </ul>
    </Scroller>
  </div>
</template>

<script>
// import BScroll from "better-scroll";
export default {
  name: "NowPlaying",
  data() {
    return {
      hotMoive: [],
      pullDown: "",
      isLoading: true,
    };
  },
  mounted() {
    this.axios.get("hotMovies").then((resp) => {
      if (resp.status === 200) {
        this.hotMoive = resp.data;
        this.isLoading=false
      }
    });
  },
  methods: {
    handleToDetail() {
      console.log(111);
    },
    handleToScroller(pos) {
      if (pos.y > 40) {
        this.pullDown = "往下拉更新数据";
      }
    },
    hanleToTouchEnd(pos) {
      if (pos.y > 50) {
        this.pullDown = "数据更新成功";
        // this.isLoading=false
        setTimeout(() => {
          this.pullDown = "";
        }, 2000);
      }
    },
  },
};
</script>

<style scoped>
#content .movie_body {
  flex: 1;
  overflow: auto;
}
.movie_body ul {
  margin: 0 12px;
  overflow: hidden;
}
.movie_body ul li {
  margin-top: 12px;
  display: flex;
  align-items: center;
  border-bottom: 1px #e6e6e6 solid;
  padding-bottom: 10px;
}
.movie_body .pic_show {
  width: 64px;
  height: 90px;
}
.movie_body .pic_show img {
  width: 100%;
}
.movie_body .info_list {
  margin-left: 10px;
  flex: 1;
  position: relative;
}
.movie_body .info_list h2 {
  font-size: 17px;
  line-height: 24px;
  width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.movie_body .info_list p {
  font-size: 13px;
  color: #666;
  line-height: 22px;
  width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.movie_body .info_list .grade {
  font-weight: 700;
  color: #faaf00;
  font-size: 15px;
}
.movie_body .info_list img {
  width: 50px;
  position: absolute;
  right: 10px;
  top: 5px;
}
.movie_body .btn_mall,
.movie_body .btn_pre,
.movie_body .btn_pre2 {
  width: 47px;
  height: 27px;
  line-height: 28px;
  text-align: center;
  background-color: #f03d37;
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.movie_body .btn_pre {
  background-color: #f03d37;
}
.movie_body .btn_pre2 {
  background-color: #3c9fe6;
}
.movie_body .pullDown {
  margin: 0;
  padding: 0;
  border: none;
}
</style>
